﻿<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Very Simple JavaScript Formula Example</title>
<script type="text/javascript" src="vsjsformulaClassV2.js"></script>
<script type="text/javascript">
//using html5 js... if you want to be backwards compatible then be my guest & write your own js
window.onload = function(){
	var x = document.querySelectorAll('.jsmath');
	for(var i = 0; i < x.length; i++){
		x[i].innerHTML = vsjsformula.translate(x[i].innerHTML);
	}
	document.getElementById('input').focus();
}

function parse(){
    var timestart = new Date();

	var input = document.getElementById('input').value;
	input = vsjsformula.translate(input);
	document.getElementById('result').innerHTML = input;
	document.getElementById('ta').value = input;
    
    document.getElementById('timex').innerHTML = ((new Date()) - timestart) + 'ms';
}
</script>
<link href="vsjsformulaStyle.css" rel="stylesheet" type="text/css">
<style type="text/css">
body {
    margin-top:1cm;
}
#timex {
    top:0;
    left:5px;
    position:absolute;
    width:50px;
    height:25px;
}
form {
	text-align:center;
}
#input {
	text-align:center;
	width:90%;
	font-size:110%;
}
#result {
	vertical-align:top;
	background-color:#DBFFE2;
	width:95%;
	min-height:30px;
}
textarea {
	display:block;
	text-align:center;
	width:100%;
}
</style>
</head>
<body>

<div id="timex">000ms</div>

<p>The string "f(x) = {3 / 6.4} * (2^65 // x)" is converted to:</p>
<div class="jsmath">f(x) = {3 / 6.4} * (2^65 // x)</div>

<p>This is a live example - type in some text and watch it transform live:</p>
<form onsubmit="return false">
	<input type="text" onkeyup="parse()" name="input" id="input">
</form>
<div id="result" class="jsmath">&nbsp;</div>
<textarea id="ta"></textarea>

</body>
</html>
